package com.zhangshuo.patternDesign.singleton;

/**
 * Created by shuo.zhang on 2017-10-17.
 */
public class BadSingleton {

    private BadSingleton() {
        try {
            Thread.sleep(2);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    private static BadSingleton instance;


    public static BadSingleton getInstance() {


        //在多线程情况下，会出现实例化多个对象的情况
        if (instance == null) {
            instance = new BadSingleton();
        }

        return instance;

    }
}
